package org.dxy.infrastructure.persistent.db.mybatispuls.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.dxy.infrastructure.persistent.db.mybatispuls.po.query.BomViewPo;
import org.dxy.infrastructure.persistent.db.mybatispuls.mapper.BomViewMapper;
import org.dxy.infrastructure.persistent.db.mybatispuls.service.BomViewService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * BOM查询服务实现
 */
@Service
public class BomViewServiceImpl extends ServiceImpl<BomViewMapper, BomViewPo> implements BomViewService {
    
    @Override
    public BomViewPo getByProductId(Long productId) {
        LambdaQueryWrapper<BomViewPo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BomViewPo::getProductId, productId);
        return getOne(queryWrapper);
    }
    
    @Override
    public List<BomViewPo> listByProductIds(List<Long> productIds) {
        if (productIds == null || productIds.isEmpty()) {
            return List.of();
        }
        LambdaQueryWrapper<BomViewPo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(BomViewPo::getProductId, productIds);
        return list(queryWrapper);
    }
}